﻿using ConsoleApplication2.business;
using ConsoleApplication2.Entity;
using ConsoleApplication2.pushApi;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2.Dao
{             /// <summary>
///  提醒你完成学习，要参见考试
/// </summary>
    public class MyStudyProgressCmd
    {
        public static void checkData()
        {
            String sql = String.Format(@"select a.UserId from T_MyStudyProgress  as a 
left join T_ExamArrangment as b on a.ExamArrangmentId=b.Id
left join T_ExamRecord as c on a.UserId=c.UserId
where b.Year=convert(char(4),getdate(),20) and IsStudyFinished=1
and GETDATE() between b.StartTime and b.EndTime
and IsExamPassed=0 group by a.UserId  Having COUNT(a.UserId)=0 ");

            DataTable dt = MyDataHelp.GetDataTableBySQL(sql);
            String userIDs = DataRowFactory.getRataRowToString(dt);
          

            if (!string.IsNullOrEmpty(userIDs))
            {
                MessagePara par = new MessagePara();
                par.UserIds = userIDs;
                par.Title = "你已完成本年度继续教育学习任务，请尽快参加考试，祝考试顺利";
                par.MessageType = 2;
                String json = JsonHelper.SerializeObject(par);
                string url = HttpAddress.personAddress;
                HttpClientHelp.sendMessage(url, json);
            }

        }
    }
}
